package com.akw.boot3.core;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

//@EnableWebMvc // 全面接管SpringMVC, 禁用所有MVC 底层的配置
//@EnableAsync  // 开启异步
@SpringBootApplication  // SPI
public class Boot307CoreApplication {

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(Boot307CoreApplication.class);
        springApplication.run(args);
//        SpringApplication.run(Boot307CoreApplication.class, args);
    }

    // 如果想要在项目启动完成后执行一些操作，可以使用ApplicationRunner 和 CommandLineRunner
    @Bean
    public ApplicationRunner applicationRunner() {
//        return new ApplicationRunner() {
//            @Override
//            public void run(ApplicationArguments args) throws Exception {
//                System.out.println("MyApplicationListener applicationRunner: " + args);
//            }
//        };
//        return (ApplicationArguments args) -> {
//            System.out.println("MyApplicationListener applicationRunner: " + args);
//        };
        return args -> {
            System.out.println("Boot307CoreApplication applicationRunner: " + args);
        };
    }

    @Bean
    public CommandLineRunner commandLineRunner() {
        return args -> {
            System.out.println("Boot307CoreApplication commandLineRunner: " + args);
        };
    }
}
